<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="css/denglu.css">
</head>
<body>
    <a href="shouye.html">返回购物</a>
    <div class="content">
        <div class="top">
            <img src="images/logo.jpg" alt="">
        </div>
        <div class="banner">
            <p>欢迎来到银座网上商城</p>
        </div>
        <div class="login">
            <div class="login-left">
                <img src="images/dlzc.jpg" alt="">
            </div>
            <form action="">
                <div class="login-right">
                    <h1><img src="images/denglu.jpg" alt=""></h1>
                    <ul>
                        <li>
                 用户名：<input type="text" placeholder="用户名/已验证手机" class="ipt1">
                        </li>
                        <li>
                            <span>&nbsp</span>
                        </li>
                        <li>
                密&nbsp;&nbsp;&nbsp;码 : <input type="" placeholder="密码" class="ipt2">
                        </li>
                        <li><span>&nbsp</span></li>
                    </ul>
                    <div class="login-tip"></div>
                    <div class="passwrod">
                        <input type="checkbox" class="ipt3">
                        <span>记住密码</span>
                        <a href="">忘了密码？</a>
                    </div>
                    <input type="submit" value="登录" class="ipt4">
                    <p>还不是银座用户？
                        <!-- <a href=""><img src="images/zhuce.jpg" alt=""></a> -->
                        <input type="submit" value="注册" class="ipt5">
                    </p>
                </div>
            </form>
        </div>
        <div class="login-xia"></div>
    </div>
    <div class="content">
        <div class="button-link">
            <p>
                <a href="##">关于我们</a>|
                <a href="##">联系我们</a>|
                <a href="##">集贤纳才</a>|
                <a href="##">服务条款</a>|
                <a href="##">友情链接</a>|  
                <a href="##">隐私保护</a><br>
                Copyright ©2008-2011 银座网上商城 版权所有。<img src="images/eae.gif">鲁ICP备09081806号<br>服务热线: 400-658-6060 | 大宗团购热线: 0531-67890997 
            </p>
        </div>
    </div>



    <script src="jquery.2.2.4.js"></script>
    <script>



//注册
        $(".ipt5").click(function(){
        $.ajax({
            url:"/api",
            data:{
                type:"register",
                user:$(".ipt1").val(),
                pass:$(".ipt2").val()
            },
            success:res=>{
                console.log(res);
                if(res.code === 200){
                    alert("恭喜你，注册成功")
                }else if(res.code === 1){
                    alert("注册失败 账号密码重复")
                }
            },
            error:()=>{},
            dataType:"json"
        })
    })



  


    //登录
    $(".ipt4").click(function(){
        $.ajax({
            url:"/api",
            data:{
                type:"login",
                user:$(".ipt1").val(),
                pass:$(".ipt2").val()
            },
            success:res=>{
                console.log(res);
                if(res.code === 200){
                    alert("登录成功")
                    location.href="shouye.html"
                }else if(res.code === 404){
                    alert("登录失败")
                }
            },
            dataType:"json"
        })
    })
    </script>
</body>
</html>